package com.jsd2412.backend.consult.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jsd2412.backend.base.response.JsonResult;
import com.jsd2412.backend.consult.pojo.dto.ConsultQuery;
import com.jsd2412.backend.consult.pojo.dto.ConsultSaveParam;
import com.jsd2412.backend.consult.pojo.vo.ConsultVO;
import com.jsd2412.backend.consult.service.ConsultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "接待管理模块")
@RequestMapping("/v1/consult/")
public class ConsultController {
    @Autowired
    private ConsultService consultService;

    @PostMapping("save")
    @ApiOperation("保存接待")
    @ApiOperationSupport(order = 10)
    public JsonResult saveConsult(ConsultSaveParam consultSaveParam) {
        log.debug("保存接待:参数={}", consultSaveParam);
        consultService.saveConsult(consultSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    @ApiOperation("删除接待")
    @ApiOperationSupport(order = 20)
    public JsonResult deleteConsult(@PathVariable Long id) {
        log.debug("删除接待:参数={}", id);
        consultService.deleteConsult(id);
        return JsonResult.ok();
    }

    @GetMapping("select")
    @ApiOperation("查询接待")
    @ApiOperationSupport(order = 30)
    public JsonResult selectConsult(ConsultQuery consultQuery) {
        log.debug("查询接待:参数={}", consultQuery);
        List<ConsultVO> list = consultService.selectConsult(consultQuery);
        return JsonResult.ok(list);
    }
}
